package com.zc.im.util;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;

/**
 * Created by Administrator on 2017/7/8.
 */
public class JsonUtils {

    public static JSONObject strToJsonObj(String jsonStr){
        JSONObject jsonObject = null;
        if(StringUtils.isEmpty(jsonStr)){
            return jsonObject;
        }
        jsonObject = JSONObject.parseObject(jsonStr);
        return jsonObject;
    }

    public static <T> T strToClass(String json, Class<T> classOfT){
        Gson gson = new Gson();
        return gson.fromJson(json, classOfT);
    }

    public static String objToStr(Object src){
        Gson gson = new Gson();
        return gson.toJson(src);
    }
}
